package com.bajiao.app.controller.common;

import com.bajiao.app.base.AppBaseController;
import com.bajiao.common.api.vo.RestResult;
import com.bajiao.common.menu.ResultEnum;
import com.bajiao.service.config.ConfigService;
import com.bajiao.vo.config.ConfigVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;


/**
 * @Description: 系统配置
 * @Author: FanJq
 * @Date: 2024-10-10
 * @Version: V1.0
 */
@Slf4j
@Api(tags = "系统配置")
@RestController
@RequestMapping("/api/v1/config")
public class RestConfigController extends AppBaseController {
    @Autowired
    private ConfigService configServiceMove;

    @GetMapping(value = "/queryByConfigGroup")
    @ApiOperation(value = "根据分组查询系统配置")
    @ApiImplicitParam(name = "configGroup", required = true, dataType = "String")
    public RestResult<Map> queryByConfigGroup(@RequestParam String configGroup) {
        return success(ResultEnum.OPERATION_SUCCESS.getDesc(),
                configServiceMove.queryNameAndValueByGroup(configGroup));
    }

    @GetMapping(value = "/queryConfig")
    @ApiOperation(value = "按组和名称查询配置")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "configGroup", value = "configGroup", required = true, dataType = "String"),
            @ApiImplicitParam(name = "configName", value = "configName", required = true, dataType = "String")
    })
    public RestResult<ConfigVO> queryConfig(@RequestParam String configGroup, @RequestParam String configName) {
        return success(ResultEnum.OPERATION_SUCCESS.getDesc(), configServiceMove.queryConfig(configGroup, configName));
    }
}
